import douDiZhu.Card;

import java.util.*;

public class DouDiZhu {
    public static void main(String[] args) {
        List pai = init();
        xiPai(pai);
        faPai(pai);
    }

    //初始化扑克牌
    public static ArrayList init() {
        List pile = List.of("3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王", "大王");
        List type = List.of("♥", "♣", "♦", "♠");
        ArrayList list = new ArrayList();
        for (int i = 0; i < 4; i++) {
            for (int f = 0; f < 13; f++) {
                list.add(new Card((String) pile.get(f), (String) type.get(i),f));
            }
        }
        list.add(new Card((String) pile.get(13),14));
        list.add(new Card((String) pile.get(14),15));
        return list;
    }

    //洗牌
    public static void xiPai(List pai) {
        Collections.shuffle(pai);
        for (int i = 0; i < pai.size(); i++) {
            Object obj = pai.get(i);
        }
    }

    //发牌
    public static void faPai(List pai) {
        List landlord=pai.subList(0,17);
        landlord.sort(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Card c1=(Card) o1;
                Card c2=(Card) o2;
                return c1.getNumber()-c2.getNumber();
            }
        });
        List peasant1=pai.subList(17,34);
        peasant1.sort(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Card c1=(Card) o1;
                Card c2=(Card) o2;
                return c1.getNumber()-c2.getNumber();
            }
        });
        List peasant2=pai.subList(34,51);
        peasant2.sort(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Card c1=(Card) o1;
                Card c2=(Card) o2;
                return c1.getNumber()-c2.getNumber();
            }
        });
        List residue=pai.subList(51,54);
        residue.sort(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Card c1=(Card) o1;
                Card c2=(Card) o2;
                return c1.getNumber()-c2.getNumber();
            }
        });
        for (Object obj:landlord){
            System.out.print(obj+"\t");
        }
        System.out.println("\n");
        for (Object obj:peasant1){
            System.out.print(obj+"\t");
        }
        System.out.println("\n");
        for (Object obj:peasant2){
            System.out.print(obj+"\t");
        }
        System.out.println("\n");
        for (Object obj:residue){
            System.out.print(obj+"\t");
        }
    }
}
